package top.minuy.test;

/**
 * @author Minuy
 * @time 21:40
 * @date 2021/11/8
 */
public class Animal<E> {

    private E[] data;
    private int size;
    public Animal(int capacity){
        data = (E[]) new Object[capacity];
        size = 0;
    }

    public boolean add(E e){
        if (size==data.length){
            return false;
        }else {
            data[size] = e;
            size++;
            return true;
        }
    }

    public E get(E e){
        for (int i=0;i<size;i++){
            if (e.equals(data[i])){
                return data[i];
            }
        }
        return null;
    }
}
